package communicationMessages;

import database.DB;

public class ChangeAdminMessage extends Message {

	@Override
	public String getAnswer() {
		String []arr = this.content.split(delimiter);
		String ans = "changeAdmin" + delimiter;
		if (arr.length != 2)
		{
			ans+="failed wrog format";
		}
		else
		{
			String userName = arr[0];
			String newAdmin = arr[1];
			if (DB.isAdmin(userName) && DB.isUserExsit(newAdmin))
			{
				DB.changeAdmin(userName,newAdmin);
				ans+="member" + delimiter + "Success" + delimiter;
			}
			else
			{
				ans+="failed wrong format";
			}
		}
		return ans;
	}

}
